/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tuitionmanagement.DAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import tuitionmanagement.entity.ClassEntity;
import tuitionmanagement.entity.ClassType;
import tuitionmanagement.util.DBUtil;

/**
 *
 * @author XUAN
 */
public class ClassTypeDAO {

    private Connection con;
    private ResultSet rs;
    private PreparedStatement pst;
    String message = "";
    ClassEntity cl = new ClassEntity();
    //private final String sql_selectClassName = "select ClassName from Class ";
    private final String SQL_SELECT_ALL = "select * from ClassType";
    private final String SQL_INSERT = "insert into Class() values()";


    public ArrayList<ClassType> getAllType() {
        ArrayList<ClassType> list = new ArrayList<ClassType>();
        try {
            con = DBUtil.getConn();
            pst = con.prepareStatement(SQL_SELECT_ALL);
            rs = pst.executeQuery();
            while (rs.next()) {
                ClassType type = new ClassType();
                type.setId(rs.getInt("ClassTypeId"));
                type.setName(rs.getString("ClassTypeName"));
                type.setTimeStudy(rs.getInt("StudyTime"));
                list.add(type);

            }
        } catch (SQLException ex) {
            message = ex.getMessage();
        } catch (Exception ex) {
            message = ex.getMessage();
        }
        return list;
    }
}
